<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:th="http://www.thymeleaf.org"
	xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3"
	  xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<script th:inline="javascript">
/*<![CDATA[*/
   $(function(){
   	 middlegroup.ns('middlegroup.admin.menu[[${OP.menuId}]]');
   	 $('#admin_menu[[${OP.menuId}]]_datagrid').bootstrapTable({ 
		  url:[[${MENU.channel}]]+'/query',
          height: '100%',
          sortName: 'a.addTime',
          sortOrder: 'desc',
          striped: true,
          pagination: true,
          pageSize: 10,
          pageList: [10, 25, 50, 100, 200],
          search: false,
          sidePagination:'server',
          idField: 'id',
          uniqueId: 'id',
          responseHandler: responseHandler,
          queryParams: queryParams,
          minimumCountColumns: 2,
          clickToSelect: true,
          searchAlign: 'left',
          columns: [{
              checkbox: true
          }, {
              field: 'merchantName',
              title: '所属商户',
              align: 'center',
              valign: 'middle'
          },
          {
              field: 'merchantBillNo',
              title: '商户订单号',
              align: 'center',
              valign: 'middle'
          },  {
                  field: 'billNo',
                  title: '中台订单号',
                  align: 'center',
                  valign: 'middle'
              }, {
                  field: 'amount',
                  title: '交易金额',
                  align: 'center',
                  valign: 'middle'
              }, {
                  field: 'currency',
                  title: '交易币种',
                  align: 'center',
                  valign: 'middle'
              },{
                  field: 'payTime',
                  title: '交易时间',
                  align: 'center',
                  valign: 'middle',
                  sortable: true
              },{
                  field: 'status',
                  title: '订单状态',
                  formatter: function (value, row,index) {
                      if (value == "0") {
                          return '处理中';
                      }
                      if (value == "1") {
                          return '成功';
                      }
                      if (value == "2") {
                          return '失败';
                      }
                      if (value == "3") {
                          return '超时';
                      }
                      return value;
                  },
                  align: 'center',
                  valign: 'middle'
              },{
                  field: 'channelName',
                  title: '交易通道',
                  align: 'center',
                  valign: 'middle'
              },{
                  field: 'subjectName',
                  title: '交易主体',
                  align: 'center',
                  valign: 'middle'
              },{
              field: 'addTime',
              title: '订单创建时间',
              align: 'center',
              valign: 'middle',
              formatter:function(value,row,index){return new Date(value).pattern("yyyy-MM-dd HH:mm:ss")}
          }, {
              field: 'updateTime',
              title: '订单状态变更时间',
              align: 'center',
              formatter:function(value,row,index){return new Date(value).pattern("yyyy-MM-dd HH:mm:ss")},
              valign: 'middle'
          }  ]
    });
})
//导出订单
middlegroup.admin.menu[[${OP.menuId}]].export = function () {
    var merchantBillNo = $("#merchant_bill_no").val();
      var  beginTime=$("#begin_time").val();
        var endTime=$("#end_time").val();
        var serviceType=$("#service_type").val();
       var billNo=$("#bill_no").val();
    middlegroup.confirm(function () {
        location.href = "/op_export_[[${OP.menuId}]]"+"?merchantBillNo="+merchantBillNo+"&serviceType="+serviceType+"&billNo="+billNo;
    });
};
// 传递的参数
function queryParams(params) {
	return {
		pageSize : params.limit,
		pageNum : params.offset / params.limit + 1,
		sort : params.sort,
		order : params.order,
		merchantBillNo:$("#merchant_bill_no").val(),
        beginTime:$("#begin_time").val(),
        endTime:$("#end_time").val(),
		serviceType:$("#service_type").val(),
		billNo:$("#bill_no").val(),
        status:$("#status").val()
	}
}
//查询
var search = 0;
middlegroup.admin.menu[[${OP.menuId}]].search = function(){
	 if($("#name").val() !='' || $("#account").val() !=''){
		 $('#admin_menu[[${OP.menuId}]]_datagrid').bootstrapTable('refresh');
		 search++;
	 } else {
		 if(search != 0) {
			 $('#admin_menu[[${OP.menuId}]]_datagrid').bootstrapTable('refresh');
			 search = 0;
		}
	}
 }


$('.form_date').datetimepicker({
    language:  'zh-CN',
    weekStart: 1,
    todayBtn:  1,
    autoclose: 1,
    todayHighlight: 1,
    startView: 2,
    minView: 2,
    forceParse: 0
});

	/*]]>*/
</script>

<div class="wrapper wrapper-content animated fadeInRight">
	<div class="ibox float-e-margins">
		<div class="ibox-content">
			<div class="panel panel-default">
				<div class="panel-body">
					<form id="formSearch" class="form-horizontal">
						<div class="form-group" style="margin-top: 15px">
							<label class="control-label col-sm-1">商户订单号</label>
							<div class="col-sm-2">
								<input type="text" class="form-control" id="merchant_bill_no" />
							</div>
							<label class="control-label col-sm-1">中台订单号</label>
							<div class="col-sm-2">
								<input type="text" class="form-control" id="bill_no" />
							</div>
							<label class="control-label col-sm-1">类型</label>
							<div class="col-sm-2">
								<select class="form-control m-b" name="serviceType" id="service_type">
									<option value="IN" selected="selected">收款</option>
									<p></p>
									<option value="OUT">出款</option>
								</select>
							</div>
                            <label class="control-label col-sm-1">状态</label>
                            <div class="col-sm-2">
                                <select class="form-control m-b" name="status" id="status">
                                    <option value="" selected="selected">-请选择-</option>
                                    <p></p>
                                    <option value="0">处理中</option>
                                    <option value="1">成功</option>
                                    <option value="2">失败</option>
                                    <option value="3">超时</option>
                                </select>
                            </div>
							<div class="form-group">
								<label class="control-label col-sm-1">开始日期</label>
								<div class="input-group date form_date col-md-2" data-date-format="yyyy-mm-dd"  data-link-format="yyyy-mm-dd">
									<input class="form-control" size="16" type="text" value="" readonly id="begin_time">
									<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
								</div>
								<label class="control-label col-sm-1">结束日期</label>
								<div class="input-group date form_date col-md-2"  data-date-format="yyyy-mm-dd"  data-link-format="yyyy-mm-dd">
									<input class="form-control" size="16" type="text" value="" readonly id="end_time">
									<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
								</div>
							</div>
							<div class="col-sm-4" style="text-align: left;">
								<button type="button"
									th:onclick="@{middlegroup.admin.menu{menuId}.search()(menuId=${OP.menuId})}"
									class="btn btn-primary">查询</button>
							</div>
						</div>
						<p shiro:hasRole="manager"> 有角色</p>
						<p shiro:hasPermission ="sys:bills:list">有操作权限</p>
					</form>
				</div>
			</div>
			<div th:include="toolbar :: toolbar-operate"></div>
			<div class="table-responsive">
				<table th:id="@{admin_menu{menuId}_datagrid(menuId=${OP.menuId})}"
					data-toolbar="#toolbar" data-show-refresh="true"
					data-show-toggle="true" data-show-columns="true"
					data-show-footer="false" data-mobile-responsive="true">
				</table>
			</div>
		</div>
	</div>
</div>
</html>
